<?php
// 公共头部的数据调取
	
	use Common\Model\Cate;
	use Common\Model\User;
	use Common\Model\Goods;
	

	$categoryModel=new Cate;
	$userModel=new User;
	$goodsModel=new Goods;
	


// 一：热门搜索下面的数据
	$searchData=$goodsModel->orderBy('click','desc')->limit(6)->get();
	

	
//注意 ，在往首页调数据的时候，其实在控制器中我们已经要把想要循环的数据格式组合好了，就等前台去循环了，一且数据格式都尽量放到控制器中来完成
	//二：头部分类数据
	$cateData=$categoryModel->where('pid=0')->get();
	
	foreach($cateData as $k=>$v){
		$cateData[$k]['twomenu']=$categoryModel->where("pid={$v['cid']}")->get();
		$cateData[$k]['two_three']=$categoryModel->where("pid={$v['cid']}")->limit(3)->get();
	}

	foreach($cateData as $k=>$v){
		foreach($v['twomenu'] as $kk=>$vv) {
			$cateData[$k]['twomenu'][$kk]['threemenu']=$categoryModel->where("pid={$vv['cid']}")->get();
		}
	}	

	// 看用户是否登录，如果登录的话，获得用户相应的信息
	if(isset($_SESSION['info'])){
		$userData=$userModel->where("uid={$_SESSION['info']['uid']}")->find();
	}



?>






<!--公共的头部-->
		<div class="top-banner" id="top-banner-block"></div>

		<!--顶部的快捷方式-->
		<div class="shortcut">
			<div class="layout">
				<div class="s-sub">
					<ul>
						<li class="s-hw">
							<a href="{{U('Index/index')}}">大雷官网</a>
						</li>
					
					</ul>
				</div>

				<div class="s-main">
					<ul>
					<?php 
					if(isset($userData)){
					?>
						<li class="s-login" id="unlogin_status">
							<a href="{{U('Person/index',['uid'=>$userData['uid']])}}">{{$userData['username']}}</a> |
							<a href="{{U('Login/out')}}">退出</a>
						</li>
						<li class="s-myOrders">
							<a href="{{U('Person/index')}}" rel="nofollow" timetype="timestamp">我的订单</a>
						</li>
					<?php  }else{?>	
						<li class="s-login" id="unlogin_status">
							<a href="{{U('Login/register')}}">注册</a>
							<a href="{{U('Login/index')}}">登录</a>
						</li>
						<li class="s-myOrders">
							<a href="{{U('Login/index')}}" rel="nofollow" timetype="timestamp">我的订单</a>
						</li>
					<?php }?>	
					</ul>
				</div>
			</div>
		</div>
		<!--顶部的快捷方式结束-->

		<!--<script src="Public/Home/js/base.js"></script>


<!--页面头部开始-->
		<header class="header">
			<div class="layout">

				<!---logo-start -->
				<div class="logo logo-index">
					<a href="{{U('Index/index')}}" title="大雷商城"><img src="Public/Home/images/logo.jpg" alt="大雷商城"></a>
				</div>
				<!---logo-start -->

				<!--搜索条-焦点为search-form增加className:hover -start -->
				<div class="searchBar">
					<!-- 页头热门搜索 -->
					<div class="searchBar-form" id="searchBar-area">
						<form method="post" action="{{U('Search/index')}}">
							<label for="search-kw" class="text" style="display: block; position: absolute; cursor: text; float: left; z-index: 2; color: rgb(153, 153, 153);">
							</label>
							<input autocomplete="off" style="z-index: 1;" class="text"   placeholder="搜索" maxlength="100" id="search-kw" name="search" type="text">
							<input class="button"   name=""   value="搜索"   type="submit">
							<input id="default-search" value="" type="hidden">
						</form>
					</div>

					<div class="searchBar-key">
						<b>热门搜索：</b>
						{{foreach from="$searchData"  value="$v"}}
							<a href="{{U('Detail/index',['gid'=>$v['gid']])}}" target="_blank">{{$v['gname']}}</a>
						{{endforeach}}
					</div>

				</div>
				<!-- 搜索条-end -->

				<!-- 头部-工具栏-start -->
			
				<div class="header-toolbar">
					<!-- 头部-工具栏-焦点为header-toolbar-item增加ClassName:hover -->
					<div class="header-toolbar-item" id="header-toolbar-imall">
						<!-- 我的商城-start -->
						<div class="i-mall">
						{{if value="isset($userData)"}}
							<div class="h">
								<a href="{{U('Person/index')}}" rel="nofollow" timetype="timestamp">我的商城</a>
								<i></i><s></s><u></u>
							</div>
							<div class="b" id="header-toolbar-imall-content">

								<div class="i-mall-prompt" id="cart_unlogin_info">
									<p>欢迎：&nbsp;&nbsp;
										<a href="{{U('Person/index')}}" rel="nofollow">{{$userData['username']}}</a> |
										<a href="{{U('Login/out')}}" rel="nofollow">退出</a>
									</p>
								</div>
								<div class="i-mall-uc " id="cart_login_info">
									<ul>
										<li>
											<a href="{{U('Person/index')}}" rel="nofollow" timetype="timestamp">我的订单</a>
										</li>
									</ul>
								</div>
							</div>
						{{else}}
							<div class="h">
								<a href="{{U('Login/index')}}" rel="nofollow" timetype="timestamp">我的商城</a>
								<i></i><s></s><u></u>
							</div>
							<div class="b" id="header-toolbar-imall-content">

								<div class="i-mall-prompt" id="cart_unlogin_info">
									<p>你好，请&nbsp;&nbsp;
										<a href="{{U('Login/index')}}" rel="nofollow">登录</a> |
										<a href="{{U('Login/register')}}" rel="nofollow">注册</a>
									</p>
								</div>
								<div class="i-mall-uc " id="cart_login_info">
									<ul>
										<li>
											<a href="{{U('Login/index')}}" rel="nofollow" timetype="timestamp">我的订单</a>
										</li>
									</ul>
								</div>
							</div>
						{{endif}}
						</div>
						<!-- -我的商城-end -->
					</div>

					<div class="header-toolbar-item" id="header-toolbar-minicart">
					<?php 
						if(isset($_SESSION['cart']['goods'])){
					?>
						<!-- -迷你购物车-start -->
						<div class="minicart" >
							<div class="h" id="header-toolbar-minicart-h">
								<a href="{{U('Gwc/carOne')}}" rel="nofollow" timetype="timestamp">我的购物车<span><em id="header-cart-total">{{count($_SESSION['cart']['goods'])}}</em><b></b></span></a><i></i><s></s><u></u>
							</div>
							<div class="b" id="header-toolbar-minicart-content" style=" height:100px" >
								<div class="minicart-pro-empty" id="minicart-pro-empty" >
									<span class="icon-minicart"   style="font-size:20px;color:#D25527;margin-top:-16px; display: block; float: left;margin-left">购物车有货，请速下单</span>
									<img src="Public/Home/images/pp.jpg" style="margin-top:-49px"/>
								</div>
							</div>
						</div>
						<!---迷你购物车-end -->
						<?php  }else{?>
							<!-- -迷你购物车-start -->
							<div class="minicart">
								<div class="h" id="header-toolbar-minicart-h">
									<a href="{{U('Gwc/carOne')}}" rel="nofollow" timetype="timestamp">我的购物车<span><em id="header-cart-total">0</em><b></b></span></a><i></i><s></s><u></u>
								</div>
								<div class="b" id="header-toolbar-minicart-content">
									<div class="minicart-pro-empty" id="minicart-pro-empty">
										<span class="icon-minicart">您的购物车是空的，赶紧选购吧！</span>
									</div>
								</div>
							</div>
							<!---迷你购物车-end -->
						<?php }?>
					</div>
				</div>
				
			</div> 
		</header>
		<!-- -头部-end -->

		<!--页面头部结束-->

		<div class="naver-main">
			<div class="layout">
				<!-- 20140823-分类-start -->
				<div class="category" id="category-block">
					<!-- 20140822-分类-start -->
					<div class="h">
						<h2>全部商品</h2>
						<i class="icon-category"></i>
					</div>
					<div class="b">
						<ol class="category-list">
							<!-- 鼠标悬停增加ClassName： hover -->
						{{foreach from='$cateData' value='$v'}}
							<li class="category-item ">
								<div class="category-info">
									<h3>
										<a href="{{U('List/index',['cid'=>$v['cid']])}}" target="_blank"><span>{{$v['cname']}}</span></a>
													
									</h3>
									{{foreach from="$v['two_three']" value="$vv"}}
										<a href="{{U('List/index',['cid'=>$vv['cid']])}}" target="_blank"><span>{{$vv['cname']}}</span></a>
									{{endforeach}}
								</div>

								<div class="category-panels children-col-1">
									<ul class="subcate-list children-col-list">
									{{foreach from="$v['twomenu']" value="$vvv"}}
										<li class="subcate-item">
											<a href="{{U('List/index',['cid'=>$vvv['cid']])}}" target="_blank"><span>{{$vvv['cname']}}</span></a>
										</li>
									{{endforeach}}
										<dl class="category-banner children-col-2">
											<dt><span>推荐商品</span></dt>
										</dl>
									</ul>
								</div>
							</li>
						{{endforeach}}	
						</ol>
					</div>
				</div>
				<!-- -分类-end -->

				<!-- -导航-start -->
				<nav class="naver">
					<ul id="naver-list">
					<li class="" id="index">
							<a href="{{U('Index/index')}}" class="current"><span>首 页</span></a>
					</li>
					{{foreach from="$cateData" value="$v"}}
						
						<li class="" id="honor">
							<a href="{{U('List/index',array('cid'=>$v['cid']))}}" class="current" target="_blank"><span>{{$v['cname']}}</span></a>
						</li>
					{{endforeach}}		
					</ul>
				</nav>
				<!-- -导航-end -->
			</div>
		</div>
<!--上边的内容是可以作为分页头部来分开的-->
		


